package com.woniuxy.controller;

import com.woniuxy.entity.RbacManager;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/rbacManager")
@CrossOrigin
public class RbacManagerController {
    @Autowired
    RbacManagerService rbacManagerService;

    @PostMapping("/manager")
    public ResponseEntity addOne(@RequestBody RbacManager rbacManager){
        return rbacManagerService.addOne(rbacManager);
    }
    @DeleteMapping("/manager/{id}")
    public ResponseEntity deleteOne(@PathVariable int id){
        return rbacManagerService.deleteOne(id);
    }


    @PutMapping("/manager")
    public ResponseEntity updateOne(@RequestBody RbacManager rbacManager){
        System.out.println(rbacManager);
        return rbacManagerService.updateOne(rbacManager);
    }
    @GetMapping("/manager/{id}")
    public ResponseEntity findOne(@PathVariable int id){
        return rbacManagerService.findOne(id);
    }
    //根据用户名和状态查询一个
    @GetMapping("/manager01/{account}/{status}")
    public ResponseEntity findOne(@PathVariable String account,@PathVariable String status){
        return rbacManagerService.findOneByAccountAndStatus(account,status);
    }

    //查询所有
    @GetMapping("/manager")
    public ResponseEntity findAll(){
        return rbacManagerService.findAll();
    }

    @GetMapping("/manager/{currentPage}/{pageSize}")
    public ResponseEntity findAll(@PathVariable int currentPage,@PathVariable int pageSize){
        return rbacManagerService.findAll(currentPage,pageSize);
    }
}
